﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class GuanQia : MonoBehaviour {

	RawImage image;
	Image xuanzeguanqia_image;
	//是否过关
	bool is_guoguan = false;
	//选择的关卡
	public static int level_number = 0;
	void Start () {
	
		image = transform.Find("/Canvas/1/RawImage-1").GetComponent<RawImage>();
		EventTriggerListener.Get(image.gameObject).onClick = OnButtonClick;
		xuanzeguanqia_image = transform.Find("/Canvas/xuanzeguanqia_image").GetComponent<Image>();
		EventTriggerListener.Get(xuanzeguanqia_image.gameObject).onClick = OnchooseLevel;

	}
	

	void Update () {
	
		if(is_guoguan)
		{
			image.texture = Resources.Load<Texture>("Texture/UI1");
		}else{
			image.texture = Resources.Load<Texture>("Texture/xin");
		}
	}
    
	//第一关
	private void OnButtonClick(GameObject go)
	{
		level_number = 1;
		is_guoguan = true;
	}

	void OnchooseLevel(GameObject go)
	{
		if(level_number != 0)
		{
		   //LoadScene.name = "XuanZeZhanJi";
		  // Application.LoadLevel("Load");
            Application.LoadLevel("XuanZeZhanJi");
		}
	}
}
